//
//  WaitTakeDetailViewController.m
//  rrqs
//
//  Created by 杜文杰 on 2018/8/24.
//

#import "WaitTakeDetailViewController.h"
#import "OrderDetailCell.h"
#import "UnusualAlertView.h"

#define BGCOLOR "F1F1F1"

@interface WaitTakeDetailViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *mainTableView; // 主框架
@property (nonatomic, strong) UIView *headerView;
@property (nonatomic, strong) UIView *footerView;
@property (nonatomic, strong) UILabel *orderIdLabel; // 订单编号
@property (nonatomic, strong) UILabel *payTypeLabel;// 支付方式
@property (nonatomic, strong) UILabel *titleLabel;// 店铺名
@property (nonatomic, strong) UILabel *dateLabel; // 下单日期
@property (nonatomic, strong) UILabel *totalMoneyLabel;// 总计金额
@property (nonatomic, strong) UIButton *bottomBtn; // 地址
@property (nonatomic, strong) NSArray *dataArray; //
@property (nonatomic, strong) NSString *site_phoneStr; // 联系商家
@property (nonatomic, strong) NSString *gkPhoneStr; // 联系顾客
@property (nonatomic, strong) UIButton *sjBtn; // 联系商家
@property (nonatomic, strong) UIButton *gkBtn; // 联系顾客
@property (nonatomic, strong) UIButton *makeSureBtn; // 确认取货

@property (nonatomic, strong) NSString *latitude; // 始发地
@property (nonatomic, strong) NSString *longitude; // 始发地
@property (nonatomic, strong) NSString *destination; //导航目的地

@property (nonatomic, strong) UIButton *unusualBtn; // 异常上报

@property (nonatomic, strong) NSArray *unusualLabelArray; // 异常上报
//商店名称
@property (strong, nonatomic) UILabel *shopNameLabel;
//商店地址
@property (strong, nonatomic) UILabel *shopDizhiLabel;
//客户名称
@property (strong, nonatomic) UILabel *gukeNameLabel;
//客户地址
@property (strong, nonatomic) UILabel *gukeDizhiLabel;
//派单时间
@property (strong, nonatomic) UILabel *paidanLabel;
//接单时间
@property (strong, nonatomic) UILabel *jiedanLabel;
//到店时间
@property (strong, nonatomic) UILabel *daodianLabel;

@end

@implementation WaitTakeDetailViewController
- (void)getLabelQueryData {
    
//    [self showHUD];
    NSDictionary* arg = @{@"ince":@"get_abnormal_reason"};
    [DBNet PostURL:kHost parameters:arg succeed:^(NSDictionary *data) {
        NSLog(@"-----%@",data);
        NSInteger flag = [[data objectForKey:@"status"]integerValue];
        if(flag == 1){
            
            self.unusualLabelArray = [NSArray arrayWithArray:[data objectForKey:@"list"]];
        }else{
            
            [self alertHUD:[data objectForKey:@"msg"]];

        }
        
        [self hidHUD];
        
    } failure:^(NSError *error) {
        [self alertHUD:@"网络异常"];
    }];
}
// 界面数据源
- (void)queryData {

    //    NSDictionary* arg = @{@"ince":@"get_order_info",@"order_id":self.waiMaiDodelHList.order_id,@"emp_id":[UserModel sharedInstanced].userId};
    NSDictionary* arg = @{@"ince":@"get_order_infos",@"main_id":self.waiMaiDodelListitems.order_id,@"emp_id":[UserModel sharedInstanced].userId};
    [DBNet PostURL:kHost parameters:arg succeed:^(NSDictionary *data) {
        [WMHelper outPutJsonString:data];
        NSInteger flag = [[data objectForKey:@"status"]integerValue];
        if(flag == 1){
            NSDictionary* dict = [data objectForKey:@"order"];
            NSArray *array = dict[@"items"];
            
            self.orderIdLabel.text = [NSString stringWithFormat:@"%@",dict[@"main_id"]];
            if (![WMHelper isNULLOrnil:array]) {
                NSDictionary *dataDic = array[0];
                self.titleLabel.text = dataDic[@"site_name"];
//                if ([dataDic[@"paytype"] isEqualToString:@"2"]) {
//                    self.payTypeLabel.text = @"微信支付";
//                }else
//                {
//                    self.payTypeLabel.text = @"其他支付";
//                }
                
                self.payTypeLabel.text = dict[@"pay_name"];

                
                self.dateLabel.text = dataDic[@"add_time"];
                self.totalMoneyLabel.text = dataDic[@"food_amount"];
                [self.bottomBtn setTitle:dataDic[@"site_addr"] forState:UIControlStateNormal];
                self.dataArray = dataDic[@"foods"];
                self.site_phoneStr = dataDic[@"site_phone"];
                self.gkPhoneStr = dataDic[@"phone"];
                
                self.longitude = dataDic[@"longitude"];
                self.latitude = dataDic[@"latitude"];
                self.destination = dataDic[@"site_addr"];
                
                
                
                self.shopNameLabel.text = dataDic[@"site_name"];
                self.shopDizhiLabel.text = dataDic[@"site_addr"];
                
                self.gukeNameLabel.text = [NSString stringWithFormat:@"%@/%@",dataDic[@"uname"],dataDic[@"phone"]];
                self.gukeDizhiLabel.text = dict[@"sendaddress"];


                self.paidanLabel.text = dict[@"paidan_time"];
                self.jiedanLabel.text = dict[@"jiedan_time"];
                self.daodianLabel.text = dict[@"daodian_time"];

                

//                if ([dataDic[@"status"] isEqualToString:@"7"]) {
//                    [self.makeSureBtn setTitle:@"配送中" forState:UIControlStateNormal];
//                    [self.makeSureBtn setBackgroundColor:getColor(@BGCOLOR)];
//                    self.makeSureBtn .enabled = YES;
//                }
            }
            
            
            [self.mainTableView reloadData];
            [self.mainTableView.mj_header endRefreshing];
        }else{
            [self alertHUD:[data objectForKey:@"fail"]];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } failure:^(NSError *error) {
        [self alertHUD:@"网络异常"];
        [self.mainTableView.mj_header endRefreshing];
    }];
}
- (void)makeSureQueryData {

    [self showHUD];
    NSDictionary* arg = @{@"ince":@"qs_get_food",@"order_id":self.waiMaiDodelListitems.order_id,@"emp_id":[UserModel sharedInstanced].userId};
    [DBNet PostURL:kHost parameters:arg succeed:^(NSDictionary *data) {
//        [self queryData];
        [WMHelper outPutJsonString:data];
        NSInteger flag = [[data objectForKey:@"status"]integerValue];
        if(flag == 1){
            NSString *sucess = data[@"sucess"];
            [self hidHUD: sucess success:YES complete:^{
                [self.navigationController popViewControllerAnimated:YES];
            }];
        }else{
            NSLog(@"%@",[data objectForKey:@"fail"]);
            [self hidHUD:[data objectForKey:@"fail"]];
        }
        
//        NSLog(@"成功");
//        NSString *sucess = data[@"sucess"];
//        [self hidHUD: sucess success:YES complete:^{
//            [self.navigationController popViewControllerAnimated:YES];
//        }];
        
    } failure:^(NSError *error) {
        [self alertHUD:@"网络异常"];
    }];
}
//确认送达
-(void)makeSureDeliveryData{
    
    [self showHUD];
    
    NSDictionary* arg = @{@"ince":@"qs_send_food",
                          @"emp_id":self.Identity.userInfo.userID,
                          @"order_id":self.waiMaiDodelListitems.order_id
                          
                          };
    [DBNet PostURL:kHost parameters:arg succeed:^(NSDictionary *data) {
        [WMHelper outPutJsonString:data];
        NSInteger flag = [[data objectForKey:@"status"]integerValue];
        if(flag == 1){
            NSString *sucess = data[@"sucess"];
            [self hidHUD: sucess success:YES complete:^{
                [self.navigationController popViewControllerAnimated:YES];
            }];
        }else{
            NSLog(@"%@",[data objectForKey:@"fail"]);
            [self hidHUD:[data objectForKey:@"fail"]];
        }
//        [self queryData];
    } failure:^(NSError *error) {
        NSLog(@"%@",error.description);
        [self hidHUD:@"网络异常"];
    }];
}

//确定上报
-(void)sureAbnormalUpload:(NSString *)text withMarkId:(NSString *)markId{
    
    [self showHUD];
    NSDictionary* arg = @{
                          @"ince":@"post_abnormal",
                          @"order_id":self.waiMaiDodelListitems.order_id,
                          @"emp_id":[UserModel sharedInstanced].userId,
                          @"mark_id":markId,
                          @"reason":text
                          };
    [DBNet PostURL:kHost parameters:arg succeed:^(NSDictionary *data) {
        
        NSInteger flag = [[data objectForKey:@"status"]integerValue];
        if(flag == 1){
            
            NSLog(@"成功了没====%@",data);
            NSString *sucess = data[@"msg"];
            [self hidHUD: sucess success:YES complete:^{
                [self.navigationController popViewControllerAnimated:YES];
            }];
            
        }else{
            [self hidHUD:[data objectForKey:@"msg"]];
        }
        
    } failure:^(NSError *error) {
        [self hidHUD:@"网络异常"];
    }];
    
}

- (void) btnAction:(UIButton *)btn
{
    if ([btn isEqual:self.sjBtn]) {
        [self callPhone:self.site_phoneStr];
    }
    if ([btn isEqual:self.gkBtn]) {
        [self callPhone:self.gkPhoneStr];
    }
    if ([btn isEqual:self.makeSureBtn]) {
        if (self.isPeiSongz) { // 配送中  确认送达 接口
            [self makeSureDeliveryData];
        }else{
            [self makeSureQueryData]; // 待取货   确认取货 接口
        }
    }
    
    if ([btn isEqual:self.bottomBtn]) {

        [CommonUntils naviAddressWithDestination:self.destination withLatitude:self.latitude withLongitude:self.longitude withController:self];
    }
    
    
    if ([btn isEqual:self.unusualBtn]) {
        
        UnusualAlertView *alertView = [[UnusualAlertView alloc] initUnusualAlertWithData:self.unusualLabelArray];
        alertView.unusualHandleBlock = ^(NSString * _Nonnull text, NSString * _Nonnull markIdStr) {
            
            NSLog(@"text = %@",text);
            NSLog(@"markIdStr = %@",markIdStr);
            
            [self sureAbnormalUpload:text withMarkId:markIdStr];
            
        };
        
        [alertView showAlertView];
    }
    
    
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"订单详情";
    [self getLabelQueryData];
    [self queryData];
    [self.view addSubview:self.mainTableView];
    if (self.isPeiSongz) { // 配送中  确认送达
        [self.makeSureBtn setTitle:@"确认送达" forState:UIControlStateNormal];
    }
}
#pragma mark -UITableViewDelegate,UITableViewDataSource
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40 / HEIGHT_6S_SCALE;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    OrderDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([OrderDetailCell class])];
    if (self.dataArray.count > 0) {
        cell.dataDic = self.dataArray[indexPath.row];
    }
    // 横线
    UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectZero];
    lineView2.backgroundColor = getColor(@BGCOLOR);
    [cell.contentView addSubview:lineView2];
    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(cell.contentView.mas_bottom).offset(-1 / HEIGHT_6S_SCALE);
        make.left.right.equalTo(cell.contentView);
        make.height.mas_equalTo(1 / HEIGHT_6S_SCALE);
    }];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.01f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.01)];
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.01)];
    return view;
}
#pragma mark - init
- (UITableView *)mainTableView
{
    if (!_mainTableView) {
        _mainTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - SafeAreaBottomHeight - SafeAreaTopHeight) style:UITableViewStyleGrouped];
        _mainTableView.backgroundColor = getColor(@BGCOLOR);
        _mainTableView.tableHeaderView = self.headerView;
        _mainTableView.tableFooterView = self.footerView;
        _mainTableView.delegate = self;
        _mainTableView.dataSource = self;
        _mainTableView.showsVerticalScrollIndicator = NO;
        _mainTableView.showsHorizontalScrollIndicator = NO;
        _mainTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        // 动态行高
        _mainTableView.rowHeight = UITableViewAutomaticDimension;
        // 预估行高
        _mainTableView.estimatedRowHeight = 80;
        [_mainTableView registerClass:[OrderDetailCell class] forCellReuseIdentifier:NSStringFromClass([OrderDetailCell class])];
        //刷新、加载
        _mainTableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            [self queryData];
        }];
    }
    return _mainTableView;
}
- (UIView *)headerView
{
    if (!_headerView) {
        _headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 320 / HEIGHT_6S_SCALE)];
        _headerView.backgroundColor = [UIColor whiteColor];
        __weak typeof(self) weakself = self;
        // 订单编号
        UILabel *orderIdLabel = [[UILabel alloc]init];
        orderIdLabel.text  =@"订单编号";
        orderIdLabel.backgroundColor = getColor(whiteColor);
        orderIdLabel.font = DEF_FontSize_14;
        orderIdLabel.textAlignment = NSTextAlignmentLeft;
        [_headerView addSubview:orderIdLabel];
        [orderIdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_headerView.mas_top);
            make.left.equalTo(_headerView.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(30 / HEIGHT_6S_SCALE);
        }];
        
        //复制
        UILabel *copyLabel = [[UILabel alloc]init];
        [_headerView addSubview:copyLabel];
        [copyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(_headerView).offset(-10 / WIDTH_6S_SCALE);
            make.centerY.equalTo(orderIdLabel.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(35, 18));
        }];
        copyLabel.textColor = COLORRGB(0x999999);
        copyLabel.text = @"复制";
        copyLabel.textAlignment = 1;
        copyLabel.font = kFontNameSize(11);
        copyLabel.layer.cornerRadius = 3;
        copyLabel.layer.masksToBounds = YES;
        copyLabel.layer.borderColor = COLORRGB(0x999999).CGColor;
        copyLabel.layer.borderWidth = 1;
        [copyLabel setUserInteractionEnabled:YES];
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAciton)];
        [copyLabel addGestureRecognizer:tap];
        
        self.orderIdLabel = [[UILabel alloc]init];
        self.orderIdLabel.backgroundColor = getColor(whiteColor);
        self.orderIdLabel.font = DEF_FontSize_14;
        self.orderIdLabel.textAlignment = NSTextAlignmentRight;
        [_headerView addSubview:self.orderIdLabel];;
        [self.orderIdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.height.equalTo(orderIdLabel);
            make.right.equalTo(copyLabel.mas_left).offset(-10 / WIDTH_6S_SCALE);
        }];
        
        
        
        
        // 支付方式
        UILabel *payTypeLabel = [[UILabel alloc]init];
        payTypeLabel.text  =@"支付方式";
        payTypeLabel.backgroundColor = getColor(whiteColor);
        payTypeLabel.font = DEF_FontSize_14;
        payTypeLabel.textAlignment = NSTextAlignmentLeft;
        [_headerView addSubview:payTypeLabel];
        [payTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(orderIdLabel.mas_bottom);
            make.left.height.equalTo(orderIdLabel);
        }];
        
        
        
        self.payTypeLabel = [[UILabel alloc]init];
        self.payTypeLabel.backgroundColor = getColor(whiteColor);
        self.payTypeLabel.font = DEF_FontSize_14;
        self.payTypeLabel.textAlignment = NSTextAlignmentRight;
        [_headerView addSubview:self.payTypeLabel];;
        [self.payTypeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.height.equalTo(payTypeLabel);
            make.right.equalTo(_headerView.mas_right).offset(-10 / WIDTH_6S_SCALE);
        }];
        
        
        
        
        
        UIView *infoView = [[UIView alloc] init];
        infoView.backgroundColor = [UIColor whiteColor];
        [_headerView addSubview:infoView];
        [infoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.payTypeLabel.mas_bottom);
            make.left.right.equalTo(_headerView);
            make.height.mas_equalTo(210 / HEIGHT_6S_SCALE);
        }];
        
        UIView *line = [[UIView alloc]initWithFrame:CGRectZero];
        line.backgroundColor = getColor(@BGCOLOR);
        [infoView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(infoView);
            make.left.right.equalTo(infoView);
            make.height.mas_equalTo(1 / HEIGHT_6S_SCALE);
        }];
        
        
        
        UILabel *shopYuanLabel = [[UILabel alloc]init];
        [infoView addSubview:shopYuanLabel];
        [shopYuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(infoView.mas_left).offset(kSizeRatio(40));
            make.top.equalTo(line.mas_bottom).offset(23);
            make.size.mas_equalTo(CGSizeMake(kSizeRatio(20), kSizeRatio(20)));
        }];
        shopYuanLabel.backgroundColor = COLORRGB(0xfdcc00);
        shopYuanLabel.layer.cornerRadius = kSizeRatio(20) / 2;
        shopYuanLabel.layer.masksToBounds = YES;
        
        
        
        self.shopNameLabel = [[UILabel alloc]init];
        self.shopNameLabel.text = @"点吧超市";
        self.shopNameLabel.textColor = [UIColor blackColor];
        self.shopNameLabel.textAlignment = 0;
        self.shopNameLabel.font = kFontNameSize(14);
        [infoView addSubview:self.shopNameLabel];
        [self.shopNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line.mas_bottom).offset(18);
            make.left.equalTo(shopYuanLabel.mas_right).offset(kSizeRatio(32));
        }];
      
     
        
        self.shopDizhiLabel = [[UILabel alloc]init];
        self.shopDizhiLabel.text = @"浑南新区XXXX大厦";
        self.shopDizhiLabel.textColor = COLORRGB(0x999999);
        self.shopDizhiLabel.textAlignment = 0;
        self.shopDizhiLabel.font = kFontNameSize(11);
        [infoView addSubview:self.shopDizhiLabel];
        [self.shopDizhiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.shopNameLabel.mas_bottom).offset(4);
            make.left.equalTo(self.shopNameLabel);
            make.right.equalTo(infoView.mas_right).offset(kSizeRatio(-40));

        }];
        
        
        
        UILabel *gukeYuanLabel = [[UILabel alloc]init];
        gukeYuanLabel.backgroundColor = COLORRGB(0x04d200);
        gukeYuanLabel.layer.cornerRadius = kSizeRatio(20) / 2;
        gukeYuanLabel.layer.masksToBounds = YES;
        [infoView addSubview:gukeYuanLabel];
        [gukeYuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(infoView.mas_left).offset(kSizeRatio(40));
            make.top.equalTo(self.shopDizhiLabel.mas_bottom).offset(16);
            make.size.mas_equalTo(CGSizeMake(kSizeRatio(20), kSizeRatio(20)));
        }];
        
        
        
        self.gukeNameLabel = [[UILabel alloc]init];
        self.gukeNameLabel.text = @"哈哈/13212345678";
        self.gukeNameLabel.textColor = [UIColor blackColor];
        self.gukeNameLabel.textAlignment = 0;
        self.gukeNameLabel.font = kFontNameSize(14);
        [infoView addSubview:self.gukeNameLabel];
        [self.gukeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.shopDizhiLabel.mas_bottom).offset(12);
            make.left.equalTo(self.shopNameLabel);
        }];
        
        
        
        self.gukeDizhiLabel = [[UILabel alloc]init];
        self.gukeDizhiLabel.text = @"浑南新区XXXXXXXXXXXXXXXXX大厦";
        self.gukeDizhiLabel.textColor = COLORRGB(0x999999);
        self.gukeDizhiLabel.textAlignment = 0;
        self.gukeDizhiLabel.font = kFontNameSize(11);
        self.gukeDizhiLabel.numberOfLines = 2;
        [infoView addSubview:self.gukeDizhiLabel];
        [self.gukeDizhiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.gukeNameLabel.mas_bottom).offset(4);
            make.left.right.equalTo(self.shopDizhiLabel);
        }];
        
        
        UILabel *paidan = [[UILabel alloc]init];
        paidan.text = @"派单时间";
        paidan.textColor = [UIColor blackColor];
        paidan.textAlignment = 0;
        paidan.font = kFontNameSize(13);
        [infoView addSubview:paidan];
        [paidan mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(infoView.mas_left).offset(kSizeRatio(46));
            make.top.equalTo(self.gukeDizhiLabel.mas_bottom).offset(12);
        }];
        
        self.paidanLabel = [[UILabel alloc]init];
        self.paidanLabel.text = @"2019-05-06 15:00";
        self.paidanLabel.textColor = [UIColor blackColor];
        self.paidanLabel.textAlignment = 2;
        self.paidanLabel.font = kFontNameSize(13);
        [infoView addSubview:self.paidanLabel];
        [self.paidanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(infoView.mas_right).offset(kSizeRatio(-40));
            make.top.equalTo(paidan);
        }];
        
        
        
        
        UILabel *jiedan = [[UILabel alloc]init];
        jiedan.text = @"接单时间";
        jiedan.textColor = [UIColor blackColor];
        jiedan.textAlignment = 0;
        jiedan.font = kFontNameSize(13);
        [infoView addSubview:jiedan];
        [jiedan mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(paidan);
            make.top.equalTo(paidan.mas_bottom).offset(10);
        }];
        
        
        
        self.jiedanLabel = [[UILabel alloc]init];
        self.jiedanLabel.text = @"2019-05-06 15:00";
        self.jiedanLabel.textColor = [UIColor blackColor];
        self.jiedanLabel.textAlignment = 2;
        self.jiedanLabel.font = kFontNameSize(13);
        [infoView addSubview:self.jiedanLabel];
        [self.jiedanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.paidanLabel);
            make.top.equalTo(jiedan);
        }];
        
    
        UILabel *daodian = [[UILabel alloc]init];
        daodian.text = @"到店时间";
        daodian.textColor = [UIColor blackColor];
        daodian.textAlignment = 0;
        daodian.font = kFontNameSize(13);
        [infoView addSubview:daodian];
        [daodian mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(jiedan);
            make.top.equalTo(jiedan.mas_bottom).offset(10);
        }];
        
        
        
        self.daodianLabel = [[UILabel alloc]init];
        self.daodianLabel.text = @"2019-05-06 15:00";
        self.daodianLabel.textColor = [UIColor blackColor];
        self.daodianLabel.textAlignment = 2;
        self.daodianLabel.font = kFontNameSize(13);
        [infoView addSubview:self.daodianLabel];
        [self.daodianLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.jiedanLabel);
            make.top.equalTo(daodian);
        }];
        
        
        
        
        
        // 横线
        UIView *lineView1 = [[UIView alloc]initWithFrame:CGRectZero];
        lineView1.backgroundColor = getColor(@BGCOLOR);
        [_headerView addSubview:lineView1];
        [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(infoView.mas_bottom);
            make.left.right.equalTo(weakself.headerView);
            make.height.mas_equalTo(10 / HEIGHT_6S_SCALE);
        }];
        // 店名
        UILabel *titleLabel = [[UILabel alloc]init];
        titleLabel.backgroundColor = getColor(whiteColor);
        titleLabel.font = DEF_FontSize_14;
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.textColor = [UIColor redColor];
//        titleLabel.text = @"鸿鑫手擀面";
        self.titleLabel = titleLabel;
        [_headerView addSubview:titleLabel];
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView1.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(_headerView.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(SCREEN_WIDTH - 100 / WIDTH_6S_SCALE - 20 / WIDTH_6S_SCALE);
        }];
        // 日期时间
        UILabel *dateLabel = [[UILabel alloc]init];
        dateLabel.backgroundColor = getColor(whiteColor);
        dateLabel.font = DEF_FontSize_14;
        dateLabel.textAlignment = NSTextAlignmentRight;
//        dateLabel.text = @"08-24 09:38:44";
        self.dateLabel = dateLabel;
        [_headerView addSubview:dateLabel];
        [dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.titleLabel);
            make.right.equalTo(_headerView.mas_right).offset(-10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(120 / WIDTH_6S_SCALE);
        }];
        // 横线
        UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectZero];
        lineView2.backgroundColor = getColor(@BGCOLOR);
        [_headerView addSubview:lineView2];
        [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(titleLabel.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.right.equalTo(_headerView);
            make.height.mas_equalTo(1 / HEIGHT_6S_SCALE);
        }];
        
    }
    return _headerView;
}
- (UIView *)footerView
{
    if (!_footerView) {
        _footerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 240/ HEIGHT_6S_SCALE)];
        _footerView.backgroundColor = [UIColor clearColor];
        
        UIView *topView = [[UIView alloc]initWithFrame:CGRectZero];
        topView.backgroundColor = [UIColor whiteColor];
        topView.userInteractionEnabled = YES;
        [_footerView addSubview:topView];
        [topView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(_footerView);
//            make.height.mas_equalTo(120 / HEIGHT_6S_SCALE);
        }];
        
        
        __weak typeof(self) weakself = self;
        
        UILabel *totalPayLabel = [[UILabel alloc]init];
        totalPayLabel.textColor = getColor(textColor);
        totalPayLabel.font = DEF_FontSize_14;
        totalPayLabel.textAlignment = NSTextAlignmentLeft;
        totalPayLabel.text = @"总计";
        [topView addSubview:totalPayLabel];
        [totalPayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(topView.mas_top).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(topView.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(SCREEN_WIDTH - 80 / WIDTH_6S_SCALE - 20 / WIDTH_6S_SCALE);
        }];

        // 总计金额
        UILabel *totalMoneyLabel = [[UILabel alloc]init];
        totalMoneyLabel.textColor = getColor(textColor);
        totalMoneyLabel.font = DEF_FontSize_14;
        totalMoneyLabel.textAlignment = NSTextAlignmentRight;
        totalMoneyLabel.text = @"0.01";
        self.totalMoneyLabel = totalMoneyLabel;
        [topView addSubview:totalMoneyLabel];
        [totalMoneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(totalPayLabel);
            make.right.equalTo(topView.mas_right).offset(-10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(20 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo(80 / WIDTH_6S_SCALE);
        }];
        
        // 横线
        UIView *lineView1 = [[UIView alloc]initWithFrame:CGRectZero];
        lineView1.backgroundColor = getColor(@BGCOLOR);
        [topView addSubview:lineView1];
        [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(weakself.totalMoneyLabel.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.right.equalTo(topView);
            make.height.mas_equalTo(1 / HEIGHT_6S_SCALE);
        }];
        
        UIButton *sjBtn = [[UIButton alloc]init];
        [sjBtn setBackgroundColor:getColor(whiteColor)];
        [sjBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        sjBtn.titleLabel.font = DEF_FontSize_14;
        sjBtn.layer.borderColor = getColor(@BGCOLOR).CGColor;
        sjBtn.layer.borderWidth = 1;
        [sjBtn setTitle:@"联系商家" forState:UIControlStateNormal];
        [sjBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.sjBtn = sjBtn;
        [topView addSubview:sjBtn];
        [sjBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView1.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(topView.mas_left).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(40 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo((SCREEN_WIDTH - 40 / WIDTH_6S_SCALE) / 3);
            make.bottom.equalTo(topView.mas_bottom).offset(-10 / HEIGHT_6S_SCALE);;
        }];
        UIButton *gkBtn = [[UIButton alloc]init];
        [gkBtn setBackgroundColor:getColor(@"1EBEA8")];
        [gkBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        gkBtn.titleLabel.font = DEF_FontSize_14;
        [gkBtn setTitle:@"联系顾客" forState:UIControlStateNormal];
        [gkBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.gkBtn = gkBtn;
        [topView addSubview:gkBtn];
        [gkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView1.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(sjBtn.mas_right).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(40 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo((SCREEN_WIDTH - 40 / WIDTH_6S_SCALE) / 3);
        }];
        UIButton *makeSureBtn = [[UIButton alloc]init];
        [makeSureBtn setBackgroundColor:getColor(@"F7AB3B")];
        [gkBtn setTitleColor:getColor(blackColor) forState:UIControlStateNormal];
        makeSureBtn.titleLabel.font = DEF_FontSize_14;
        [makeSureBtn setTitle:@"确认取货" forState:UIControlStateNormal];
        [makeSureBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.makeSureBtn = makeSureBtn;
        [topView addSubview:makeSureBtn];
        [makeSureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(lineView1.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
            make.left.equalTo(gkBtn.mas_right).offset(10 / WIDTH_6S_SCALE);
            make.height.mas_equalTo(40 / HEIGHT_6S_SCALE);
            make.width.mas_equalTo((SCREEN_WIDTH - 40 / WIDTH_6S_SCALE) / 3);
        }];
        // 横线
//        UIView *lineView2 = [[UIView alloc]initWithFrame:CGRectZero];
//        lineView2.backgroundColor = getColor(@BGCOLOR);
//        [topView addSubview:lineView2];
//        [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(makeSureBtn.mas_bottom).offset(10 / HEIGHT_6S_SCALE);
//            make.left.right.equalTo(topView);
//            make.height.mas_equalTo(15 / HEIGHT_6S_SCALE);
//        }];
        
        
        
        
        
        UIView *bottomView = [[UIView alloc]initWithFrame:CGRectZero];
        bottomView.backgroundColor = [UIColor whiteColor];
        [_footerView addSubview:bottomView];
        [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(topView.mas_bottom).offset(15 / HEIGHT_6S_SCALE);
            make.left.right.equalTo(topView);
            make.height.mas_equalTo(40 / HEIGHT_6S_SCALE);
        }];
        
        
        UIImageView *locationImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_dingwei_black"]];
        [bottomView addSubview:locationImage];
        [locationImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(bottomView);
            make.left.equalTo(bottomView).offset(5);
            make.height.width.mas_equalTo(20);
        }];
        
        
        UIButton *bottomBtn = [[UIButton alloc]init];
        bottomBtn.backgroundColor = getColor(whiteColor);
        [bottomBtn setTitleColor:getColor(textColor) forState:UIControlStateNormal];
        bottomBtn.titleLabel.font = DEF_FontSize_13;
        bottomBtn.titleLabel.numberOfLines = 0;
        bottomBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//        [bottomBtn setTitle:@"新民市东环街41号" forState:UIControlStateNormal];
        [bottomBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        self.bottomBtn = bottomBtn;
        [bottomView addSubview:bottomBtn];
        [bottomBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(bottomView);
            make.left.equalTo(locationImage.mas_right);
            make.right.equalTo(bottomView).offset(-10);
        }];
        
        
        UIButton *unusualBtn = [[UIButton alloc]init];
        unusualBtn.backgroundColor = getColor(@"f5964f");
        [unusualBtn setTitleColor:[UIColor darkTextColor] forState:UIControlStateNormal];
        unusualBtn.titleLabel.font = DEF_FontSize_16;
        [unusualBtn setTitle:@"异常上报" forState:UIControlStateNormal];
        [unusualBtn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
        unusualBtn.layer.cornerRadius = 5;
        unusualBtn.layer.masksToBounds = YES;
        self.unusualBtn = unusualBtn;
        [_footerView addSubview:unusualBtn];
        [unusualBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bottomView.mas_bottom).offset(50 / HEIGHT_6S_SCALE);
            make.centerX.equalTo(_footerView);
            make.width.equalTo(_footerView).multipliedBy(0.6);
            make.height.mas_equalTo(45/ HEIGHT_6S_SCALE);

        }];
        
        
        
        
        
        
    }
    return _footerView;
}
/**
 *  拨打电话
 *
 *  @param phoneNumber 号码
 */
- (void)callPhone:(NSString *)phoneNumber{
    
    NSMutableString* str=[[NSMutableString alloc] initWithFormat:@"tel:%@",phoneNumber];
    UIWebView * callWebview = [[UIWebView alloc] init];
    [callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
    [self.view addSubview:callWebview];
    
//    UIAlertController *av = [UIAlertController alertControllerWithTitle:@"拨打电话" message:nil preferredStyle:UIAlertControllerStyleAlert];
//    UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",phoneNumber]]];
//    }];
//    UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//
//    }];
//    [av addAction:action1];
//    [av addAction:action2];
//    [self presentViewController:av animated:YES completion:nil];
}
- (NSArray *)dataArray
{
    if (!_dataArray) {
        _dataArray = [NSArray array];
    }
    return _dataArray;
}

-(void)tapAciton{
    
    
    [self alertHUD:@"复制成功"];
    UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
    pasteboard.string = [Config isBlankString:[NSString stringWithFormat:@"%@",self.orderIdLabel.text]] ? @"" : [NSString stringWithFormat:@"%@",self.orderIdLabel.text];
    NSLog(@"===%@",pasteboard.string);
    
}



@end
